﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KBManagement.DAL;
using KBManagement.Library;
namespace KBManagement
{
    public partial class EditEmployee : Form
    {
        KBSQLClassDataContext context;
        public EditEmployee(Employee employee)
        {
            context = Utils.CreateInstance().GetDBContext();
            InitializeComponent();
            txtNameEmp.Text = employee.FullName;
            txtAddressEmp.Text = employee.Address;
            txtEmailEmp.Text = employee.Email;
            txtPhoneEmp.Text = employee.Phone;
            txtYearEmp.Text = employee.BirthDay.Year.ToString();
            cbbDayEmp.SelectedIndex = employee.BirthDay.Day-1;
            cbbMonthEmp.SelectedIndex = employee.BirthDay.Month-1;
            cbbPosition.SelectedValue = employee.PositionID;
            BindingComboBox();
        }


        private void BindingComboBox()
        {
            var position = from fc in context.Positions select fc;
            cbbPosition.DataSource = position;
            cbbPosition.DisplayMember = "name";
            cbbPosition.ValueMember = "id";

            var timeSlot = from fc in context.TimeSlots select fc;
            cbbTimeSlot.DataSource = timeSlot;
            cbbTimeSlot.DisplayMember = "name";
            cbbTimeSlot.ValueMember = "id";
        }

        private void btnOk_Click(object sender, EventArgs e)
        {

        }


        
    }
}
